<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../public/css/monokai_sublime.min.css">
    <link rel="stylesheet" href="../../public/css/heightlength.css">
    <link rel="stylesheet" href="../../public/css/mxjs.css">
    <link rel="stylesheet" href="../../public/css/prism.css">
    <script src="../../public/js/jquery.js"></script>
    <script src="../../public/js/highlight.min.js"></script>
    <script src="../../public/js/prism.js"></script>
    <script src="../../public/js/clipboard.min.js"></script>

</head>
<body>
<button>点击</button>
<div class="container">
    <div class="jsbg">
        <div class="col-lg-12 mxlength">
            <div class="mx-1">
                <h2>判断对象是否为空</h2>
                <code>
                    判断是否是数组首选Object.prototype.toString.call(arr2) == '[object Array]'
                    typeof data==="object"//判断是否为对象有局限性 如 [] 判断为object {}判断为object
                    intanceof也有他的局限性new Date instanceof Object返回的是object
                   其实只有Object.prototype上的toString才能用来进行复杂数据类型的判断。
                </code>
            </div>
        </div>
        <div class="col-lg-12  ">
      <pre class="mScroll">
        <code class="lang-javascript">
    function isempty(data){
        if(Object.prototype.toString.call(data) == '[object Array]'){
            if(data.length>0){
                return false;
            }else{
                return true;
            }
        }else if(Object.prototype.toString.call(data) == '[object Object]'){

            for(let key in data) {
                return false;
            }
            return true;
        }else  if(data===""||data===null||data===undefined||data==="null"||data==="undefined"){
            return true;
        }
        return false;
    }

    let str={};
    console.log(isempty(str))
		</code>
    </pre>
        </div>
    </div>
</div>
<script>

    window.onload = function () {
        var clipboard = new Clipboard('.toolbar-item');
        clipboard.on('success', function (e) {
            console.log(e.text);
        });
        clipboard.on('error', function (e) {
            console.log(e);
        });
        $(".toolbar-item").html("<span>复制</span>")
    }
</script>
</body>
</html>
